package org.jeecg.modules.sys_captcha.config;

import org.jeecg.modules.sys_captcha.service.ISysCaptchaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class CaptchaTask {

    @Autowired
    private ISysCaptchaService captchaService;

    /**
     * 每天凌晨2点清理过期验证码
     */
    @Scheduled(cron = "0 0 2 * * ?")
    public void clearExpiredCaptchas() {
        captchaService.clearExpiredCaptchas(new Date());
    }
}
